﻿using System;
using System.Web.UI;
namespace Common.Web.Pages
{
    public class AjaxBasePage : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Error += new System.EventHandler(PageBase_Error);  //向页面注册onerror方法
            IsOnLoad();
        }

        public void IsOnLoad()
        {
            if (string.IsNullOrEmpty(new Cookie().GetCookie("LoginUser")))
            {
                Response.Write("页面已超时，请重新登录");
                Response.End();
            }
        }

        /// <summary>
        /// 错误处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PageBase_Error(object sender, System.EventArgs e)
        {
            string str = this.Page.ToString().Replace("ASP.", "") + "页面崩溃";
            str.Error();
            Response.Write("页面发生错误，请联系管理员");
            Response.End();
        }
    }
}
